package com.lindroy.controller

import com.lindroy.config.RespResult
import com.lindroy.constants.HTTP_OK
import com.lindroy.constants.ResultMsg
import com.lindroy.service.OrderService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController


/**
 * @author Lin
 * @date 2019/10/15
 * @function
 * @Description
 */
@RestController
@RequestMapping( "/order")
class OrderController {

    @Autowired
    lateinit var orderService: OrderService

    @GetMapping(value = ["/findById"])
    fun findByOrderId(@RequestParam(value = "id") id: Int) =
        RespResult(HTTP_OK, ResultMsg.FIND_SUCCESS, orderService.findById(id))

    @GetMapping(value = ["/findAll"])
    fun  findAll() = RespResult(HTTP_OK, ResultMsg.FIND_SUCCESS, orderService.findAll())
}